{% extends "base.html" %}
{% load static %}

{% block content %}
<div class="forum-container">
    <div class="post-detail-card">
        <div class="post-header">
            <img src="{{ post.author.get_avatar_url }}" alt="头像" class="post-avatar">
            <div class="post-meta">
                <span class="post-author">{{ post.author.nickname|default:post.author.username }}</span>
                <span class="post-date">{{ post.created_at|date:"Y-m-d H:i" }}</span>
            </div>
        </div>
        <h1 class="post-title">{{ post.title }}</h1>
        <div class="post-content">{{ post.content|linebreaks }}</div>
    </div>

    <div class="comment-section">
        <h3>评论</h3>
        {% for comment in comments %}
        <div class="comment-bubble">
            <img src="{{ comment.author.get_avatar_url }}" alt="头像" class="comment-avatar">
            <div class="comment-content">
                <div class="comment-meta">
                    <span class="comment-author">{{ comment.author.nickname|default:comment.author.username }}</span>
                    <span class="comment-date">{{ comment.created_at|date:"Y-m-d H:i" }}</span>
                </div>
                <p>{{ comment.content }}</p>
            </div>
        </div>
        {% endfor %}

        {% if user.is_authenticated %}
        <form method="post" class="comment-form">
            {% csrf_token %}
            {{ comment_form.content }}
            <button type="submit" class="btn-submit">发表评论</button>
        </form>
        {% endif %}
    </div>
</div>
{% endblock %}